<?php 
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu();
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
load()->func('tpl');
$pageindex = max(1, intval($_GPC['page']));
$pagesize=10;
$where=' WHERE  uniacid=:uniacid  ';
$data[':uniacid']=$_W['uniacid'];
if(isset($_GPC['keywords'])){
    $where.="  and title LIKE  concat('%', :name,'%')";
    $data[':name']=$_GPC['keywords']; 
    // $type='all';  
}
$sql="SELECT * FROM ".tablename('snx_articles') .$where." ORDER BY create_time desc";
$total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('snx_articles').$where." ORDER BY create_time desc",$data);
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);
// var_dump($list);die;
$pager = pagination($total, $pageindex, $pagesize);
if($operation=='delete'){
	$res=pdo_delete('snx_articles',array('id'=>$_GPC['id']));
	if($res){
		message('删除成功',$this->createWebUrl('articles',array()),'success');
	}else{
		message('删除失败','','error');
	}
}
if($_GPC['op']=='change'){
   $res=pdo_update('snx_articles',array('state'=>$_GPC['state']),array('id'=>$_GPC['id']));
    if($res){
        message('操作成功',$this->createWebUrl('articles',array()),'success');
    }else{
        message('操作失败','','error');
    }
}
include $this->template('web/articles');
 ?>